package com.pine.common.systemlog;

import com.alibaba.ttl.TransmittableThreadLocal;

/**
 * 系统日志上下文
 *
 * @author pine manage
 * @since 2024-08-12
 */
public class SysLogContext {

    private static final ThreadLocal<SysLogVo> SYS_LOG_THREAD_LOCAL = new TransmittableThreadLocal<>();

    public static void put(SysLogVo sysLogVo) {
        SYS_LOG_THREAD_LOCAL.set(sysLogVo);
    }

    public static SysLogVo get() {
        SysLogVo sysLogVo = SYS_LOG_THREAD_LOCAL.get();
        if (sysLogVo == null) {
            return new SysLogVo();
        }
        return sysLogVo;
    }

    public static void clean() {
        SYS_LOG_THREAD_LOCAL.remove();
    }
}
